import { getApi, postApi, service } from "../../config/request";
import { AxiosPromise } from "axios";
import { TokenInfo, LoginData, tokenData } from "./types";

// 获取单位信息Tree-当前和子级
export const reqUnitTree = (params: object = {}): AxiosPromise<tokenData> => {
  return postApi("/system/unit_info/tree", params);
};

// 获取所有单位级别
export function reqUnitsList(params: object = {}): AxiosPromise<TokenInfo> {
  return getApi("/system/unit_level/list", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
}

// 获取单位基础信息
export function reqUnitInfo(params: object = {}): AxiosPromise<TokenInfo> {
  return postApi("/system/unit_info/one", params);
}

// 获取直接下级单位列表
export function reqUnitInfoList(params: object = {}): AxiosPromise<TokenInfo> {
  return postApi("/system/unit_info/page/sub", params);
}

// 创建单位
export function reqCreateUnit(params: object = {}): AxiosPromise<TokenInfo> {
  return postApi("/system/unit_info/save", params);
}
// 修改单位
export function reqModifyUnit(params: object = {}): AxiosPromise<TokenInfo> {
  return postApi("/system/unit_info/modify", params);
}
// 删除单位
export function reqDeleteUnit(params: object = {}): AxiosPromise<TokenInfo> {
  return postApi("/system/unit_info/delete", params);
}
